using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SoundManager : MonoBehaviour {

	// Statics so they persist between level reloads
	static bool soundEnabled = true;
	static bool musicEnabled = true;

	void Start () {
		GameObject.Find ("Sound Toggle").GetComponent<Toggle>().isOn = soundEnabled;
		GameObject.Find ("Music Toggle").GetComponent<Toggle>().isOn = musicEnabled;
	}

	public void ChangeSound() {
		soundEnabled = GameObject.Find ("Sound Toggle").GetComponent<Toggle>().isOn;
		if(soundEnabled)
			AudioListener.volume = 1f;
		else
			AudioListener.volume = 0;
	}
	
	public void ChangeMusic() {
		musicEnabled = GameObject.Find ("Music Toggle").GetComponent<Toggle>().isOn;

		if(musicEnabled)
			GetComponent<AudioSource>().Play();
		else
			GetComponent<AudioSource>().Stop();
	}
	
}
